//
//  SinaFooterView.swift
//  weibo
//
//  Created by sirius on 16/1/6.
//  Copyright © 2016年 sirius. All rights reserved.
//

import UIKit

class SinaFooterView: UIView {

    var footerViewModel: SinaStatusViewModel? {
        didSet{
            retweetButton.setTitle(footerViewModel?.reposts_string, forState: UIControlState.Normal)
            commentsButton.setTitle(footerViewModel?.comment_string, forState: UIControlState.Normal)
            goodButton.setTitle(footerViewModel?.attitudes_string, forState: UIControlState.Normal)
        }
    }
    override init(frame: CGRect) {
         super.init(frame: frame)
        setupUI()
    }
    required init?(coder aDecoder: NSCoder) {
         fatalError("error")
    }
    private func setupUI(){
        addSubview(commentsButton)
        addSubview(retweetButton)
        addSubview(goodButton)
        
        commentsButton.snp_makeConstraints { (make) -> Void in
             make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(retweetButton.snp_width)
        }
        goodButton.snp_makeConstraints { (make) -> Void in
             make.right.equalTo(self.snp_right)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(retweetButton.snp_width)
        }
        //转发按钮
        retweetButton.snp_makeConstraints { (make) -> Void in
             make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            
            make.left.equalTo(commentsButton.snp_right)
            make.right.equalTo(goodButton.snp_left)
        }
        let line1 = getline()
        let line2 = getline()
        addSubview(line1)
        addSubview(line2)
        line1.snp_makeConstraints { (make) -> Void in
             make.centerY.equalTo(self.snp_centerY)
            make.left.equalTo(commentsButton.snp_right)
        }
        line2.snp_makeConstraints { (make) -> Void in
             make.centerY.equalTo(self.snp_centerY)
            make.left.equalTo(retweetButton.snp_right)
        }
     }
    lazy var retweetButton: UIButton  = {
        let button = UIButton(type: UIButtonType.Custom)
        button.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        button.setTitle("转发", forState: UIControlState.Normal)
        button.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
        return button
    }()
    lazy var commentsButton: UIButton = {
        let button = UIButton(type: UIButtonType.Custom)
        button.setImage(UIImage(named: "timeline_icon_comment"), forState: UIControlState.Normal)
        button.setTitle(" 评论", forState: UIControlState.Normal)
        button.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
        return button
    }()
     ///点赞按钮
    lazy var goodButton: UIButton = {
        let button = UIButton(type: UIButtonType.Custom)
        button.setImage(UIImage(named: "timeline_icon_like"), forState: UIControlState.Normal)
        button.setTitle("赞", forState: UIControlState.Normal)
        button.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
        return   button
    }()
    //创建一条线
    private func getline() -> UIImageView {
        return UIImageView(image: UIImage(named: "timeline_card_bottom_line_highlighted"))
    }
}
